﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Collections.Specialized;
using System.Text;

namespace LDSP
{
    public partial class AjaxAutoComplete : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string strInput = string.IsNullOrEmpty(Request.QueryString["w"]) ? string.Empty : Request.QueryString["w"];
            if (strInput.Trim().Length != 0)
            {
                //string sss = (HttpUtility.UrlDecode(Request.QueryString["w"]));
                NameValueCollection utf8Requests = HttpUtility.ParseQueryString(Request.Url.Query, Encoding.UTF8);
                Suggeste(utf8Requests.Get("w"));
            }

        }

        private void Suggeste(string originalStr)
        {
            //SqlConnection conn = new SqlConnection("data source=localhost;database=TestDB;user id=sa;password=19831016");
            //string cmdText = "SELECT TOP 10 AdminLoginId FROM AdminsInfo WHERE AdminLoginId LIKE @w";
            //SqlParameter para = new SqlParameter("@w", string.Format("{0}%", originalStr));
            //SqlCommand cmd = new SqlCommand();
            //cmd.Connection = conn;
            //cmd.CommandText = cmdText;
            //cmd.Parameters.Add(para);
            //conn.Open();
            //SqlDataReader reader = cmd.ExecuteReader();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.AppendFormat("{0},", "苹果");
            sb.AppendFormat("{0},", "苹果一代");
            sb.AppendFormat("{0},", "苹果二代");
            sb.AppendFormat("{0},", "苹果三代");
            //reader.Close();
            //conn.Close();
            Response.ContentType = "text/plain";
            Response.Clear();
            if (sb.Length != 0)
            {
                Response.Write(sb.ToString().Remove(sb.Length - 1));
            }
            else
            {
                Response.Write(string.Empty);
            }
            Response.Flush();
            Response.Close();
        }
    }
}